package com.xty.itgroup.tech05tytex.Util;

import com.alibaba.fastjson.JSONObject;

public class ResultUtil {
    public static Result success(Object object) {
        Result msg = new Result();
        Object res;
        res = object;
        if (object == null || object instanceof JSONObject) {
            res = object;
        }

        msg.setCode(0);
        msg.setMsg("success");
        msg.setData(res);
        return msg;
    }

    public static Result success() {
        return success(null);
    }

    public static Result error(Integer code, String resultmsg) {
        Result msg = new Result();
        msg.setCode(code);
        msg.setMsg(resultmsg);
        return msg;
    }

    public static Result error(ResultEnum resultEnum) {
        Result msg = new Result();
        msg.setMsg(resultEnum.getMsg());
        msg.setCode(resultEnum.getCode());
        return msg;
    }

}
